//
//  JSDSportTrackingLine.m
//  仿咕咚
//
//  Created by Abner on 16/11/10.
//  Copyright © 2016年 Abner. All rights reserved.
//

#import "JSDSportTrackingLine.h"

@implementation JSDSportTrackingLine
- (instancetype)initWithStartLocation:(CLLocation *)startLocation endLocation:(CLLocation *)endLocation{
    self = [super init];
    if (self) {
        _startLocation = startLocation;
        _endLocation = endLocation;
    }
    return self;
}
-(JSDSportMAPolyline *)polyLine{
    CLLocationCoordinate2D coords[2];
    coords[0] = _startLocation.coordinate;
    coords[1] = _endLocation.coordinate;
    //增大因子
    CGFloat factor = 8;
    CGFloat red  = self.speed * factor/255.0;
    JSDSportMAPolyline *polyLine = [JSDSportMAPolyline polylineWithCoordinates:coords count:2 color:[UIColor colorWithRed:red green:1 blue:0 alpha:1]];
    return polyLine;
}
//单位换算
-(double)speed{
    return (_startLocation.speed + _endLocation.speed) * 0.5 * 3.6;
}
- (NSTimeInterval)time{
    return [_endLocation.timestamp timeIntervalSinceDate:_startLocation.timestamp];
}
- (double)distance{
    return [_endLocation distanceFromLocation:_startLocation];
}
@end
